package com.example.system.mapper;

import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.system.entity.Role;
import com.example.system.entity.RoleAuthorityJoin;
import com.example.system.vo.RoleVo;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 *
 * @author 王令
 * @since 2022-08-05
 */
public interface RoleMapper extends BaseMapper<Role> {

    void addWithAuthorityJoins(@Param("roleId") Long roleId , @Param("authoritiesId") List<Long> authoritiesId);

    @InterceptorIgnore(tenantLine = "true")
    void addAdminRoleWithTenant(@Param("tenantId") String tenantId, @Param("roleCode") String roleCode);

    void removeWithAuthorityJoins(Long roleId);

    List<RoleAuthorityJoin> listWithAuthorityJoinByRoleId(Long roleId);

    List<RoleAuthorityJoin> listWithAuthorityJoinByRolesId(@Param("rolesId") List<Long> rolesId);

    List<RoleVo> listWithVoByUserId(Long userId);

    List<Role> listByUsername(String username);

    List<Role> listByUserId(Long userId);

    @InterceptorIgnore(tenantLine = "true")
    Role findByTenantIdAndCode(@Param("tenantId") String tenantId, @Param("code") String code);
}
